<template>
	<VueUeditorWrap v-model="message" :config="myConfig" />
</template>
<script>
import VueUeditorWrap from 'vue-ueditor-wrap';
export default {
	name: 'UEditor',
	components: {
		VueUeditorWrap
	},
	props: {
		//编辑器高度
		ueHeight: {
			type: Number,
			default: 200
		},
		//编辑器宽度
		ueWidth: {
			type: Number,
			default: 842
		},
		//编辑器默认值
		value: String
	},
	data() {
		return {
			message: this.value,
			myConfig: {
				// 编辑器不自动被内容撑高
				autoHeightEnabled: false,
				// 初始容器高度
				initialFrameHeight: this.ueHeight,
				// 初始容器宽度
				initialFrameWidth: this.ueWidth,
				// 上传文件接口
				serverUrl: '',
				UEDITOR_HOME_URL: '/UEditor/',
				zIndex: 2000,
				toolbars: [
					[
						'undo',
						'fontfamily',
						'fontsize',
						'bold',
						'indent',
						'justifyleft',
						'justifyright',
						'justifycenter',
						'forecolor',
						'imagecenter',
						'time',
						'date'
					]
				]
			}
		};
	},
	watch: {
		value(val) {
			this.message = val;
		},
		message(val) {
			this.$emit('input', val);
		}
	},
	mounted() {
		this.message = this.defaultMsg;
	}
};
</script>
